package cn.wolfcode.edu.web.controller;

import cn.wolfcode.edu.service.IClientService;
import cn.wolfcode.edu.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("clientpool")
public class ClientPoolController {

    @Autowired
    private IClientService clientService;

    //定位到潜在客户资源池网页
    @RequestMapping("")
    public String gotoClientPoolPage(){
        return "client/clientPool";
    }

    @RequestMapping("joinMe")
    @ResponseBody
    public JsonResult joinMe(Long clientId){
        try {
            clientService.joinMe(clientId);
            return new JsonResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("移交失败");
        }
    }

    //指派给谁
    @RequestMapping("dispatch")
    @ResponseBody
    public JsonResult dispatch(Long salemanId,Long clientId){
        try {
            clientService.dispatch(salemanId,clientId);
            return new JsonResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("指派失败");
        }
    }
}
